//
//  Today_debris_TagTableViewCell.m
//  Time
//
//  Created by dllo on 16/7/20.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "Today_debris_TagTableViewCell.h"


@interface Today_debris_TagTableViewCell ()
/**
 *  背景图
 */
@property (nonatomic,retain) UIImageView *backImageView;
/**
 *  背景图上的字= =||
 */
@property (nonatomic,retain) UILabel *tagLabel;

@end

@implementation Today_debris_TagTableViewCell

-(void)dealloc{
    [_model release];
    [_backImageView release];
    [_tagLabel release];
    
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.backImageView];
        [_backImageView release];
        
        self.tagLabel = [[UILabel alloc] init];
        [self.backImageView addSubview:self.tagLabel];
        [_tagLabel release];
    }
    return self;
}

-(void)layoutSubviews{
    
    self.backImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.backImageView.clipsToBounds = YES;
    [self.backImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(0);
        make.right.equalTo(self.contentView.mas_right).offset(0);
        make.top.equalTo(self.contentView.mas_top).offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
    }];
    
    self.tagLabel.font = [UIFont systemFontOfSize:17.0];
    self.tagLabel.textColor = [UIColor whiteColor];
    self.tagLabel.textAlignment = NSTextAlignmentCenter;
    [self.tagLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.backImageView).offset(0);
        make.width.mas_equalTo(SWIDTH * 0.5);
        make.height.mas_equalTo(self.contentView.bounds.size.height * 0.5);
    }];
    
}

-(void)setModel:(SCB_Today_Debris_ContentModel *)model{
    if (_model != model){
        [_model release];
        _model = [model retain];
    }
    [self.backImageView setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil];
//    NSLog(@"%@",model.img);
    self.tagLabel.text = model.tag;
}

@end
